package org.coder.consumer_nacos_openFeign_9004;

import feign.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

import java.time.Duration;

@SpringBootApplication
@EnableFeignClients
public class ConsumerNacosOpenFein9004Application {

    public static void main(String[] args) {
        SpringApplication.run(ConsumerNacosOpenFein9004Application.class, args);
    }

    @Bean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }


    @LoadBalanced
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @LoadBalanced
    @Bean
    public RestTemplate restTemplateTimeOut(RestTemplateBuilder builder) {
        //超时配置
        return builder
                .setConnectTimeout(Duration.ofDays(5000))
                .setReadTimeout(Duration.ofDays(5000))
                .build();
    }
}
